/**	\author    coidgen 0.9.2
	\version    (4.0 build 25)
	\date      
	\brief     
*/



// Service header info (for version checking),  ! DO NOT CHANGE !
static const char COID_bin_data[] =
"060005000000302E392E3209000000312E342028342E3029D30F000048BDDA4500000000000000000004000019000000"
"0500000001000000040000006D617073000000000000000000000000030000000300000003000000FFFFFFFF04000000"
"6F7063640000000000000000000080000000000F0000006765745F696D6167655F62795F58590000000002000000FFFF"
"FFFF0E00000063496D616765506F736974696F6E000000000000000000000108000000FFFFFFFF09000000634D617049"
"6D616765000000000000000000000208000000000207000000000000000000FFFFFFFF040000006F7063640000000000"
"00000000008000000000140000006765745F696D6167655F62795F6C6F6E5F6C61740100000002000000FFFFFFFF0E00"
"000063496D616765506F736974696F6E000000000000000000000108000000FFFFFFFF09000000634D6170496D616765"
"000000000000000000000208000000000207000000000000000000FFFFFFFF040000006F706364000000000000000000"
"0080000000000B0000006368616E67655F7A6F6F6D0200000002000000FFFFFFFF0E00000063496D616765506F736974"
"696F6E000000000000000000000108000000FFFFFFFF0E00000063436F6E66696775726174696F6E0000000000000000"
"0000020800000000020720000000000000000001FFFFFFFF040000006F7063640000000000000000000080000000000E"
"0000006163636570745F636F6E6E6563740500008004000000FFFFFFFF03000000696E74000000000000000000000100"
"000000FFFFFFFF03000000696E74000000000000000000000100000000FFFFFFFF03000000696E740000000000000000"
"00000100000000FFFFFFFF0E00000063436F6E66696775726174696F6E00000000000000000000020800000000028720"
"000000000000000001FFFFFFFF040000006F706364000000000000000000008000000000150000006163636570745F63"
"6F6E6E6563745F73686172656406000080000000000050802000000000000000000000000000000001000700FFFFFFFF"
"00000000"
;
//*/


#include "coid/comm/interfnc.h"
#include "maps.h"
#include "coid/comm/metastream/metastream.h"


namespace coid {


static inline const char ** COID_OUT_ARGS(const char ** from) {
	while( *from ) from++;
	return ++from;
}

typedef ServiceDescriptor::MethodDesc MethodDesc;
#define COID_MethodDesc_constructor(S,I,F)         MethodDesc( S[0], S[1], &S[2], COID_OUT_ARGS(&S[2]), I, F )
#define COID_MethodDesc_constructor_NotImpl        MethodDesc( NULL, NULL, NULL, NULL, 0, 0 )



typedef void (maps::*coid_fnc)();

/// fake function, should never be called:
static void coid_throw() {throw ersFE_EXCEPTION;}

/// we need type cast in case there are 2 or more methods with the same name
#define COID_DISPATCH_CREATE_HOOK(M,i,t,tc) \
	if( i < coid_fnc_count ) { \
		if( (coid_flags[i] & COID_maps_method_desc[i].flags & MethodDesc::xACCESS_MODE) ) \
			coid_fnc_table[t] = (coid_fnc) (tc) &maps::M; \
		else *(void **) &coid_fnc_table[t] = (void *) coid_throw; \
	}


#define COID_DISPATCH_CREATE_CALLER_HOOK(M,i,t) \
	if( i < coid_fnc_count ) { \
		if( (coid_flags[i] & COID_maps_method_desc[i].flags & MethodDesc::xACCESS_MODE) ) \
			coid_fnc_table[t] = (coid_fnc) &DISPATCH_CALLER_maps_4_0::M; \
		else *(void **) &coid_fnc_table[t] = (void *) coid_throw; \
	}






/// functions:
uint COID_maps_4_0_get_method_id( const token & name );
opcd COID_maps_4_0_dispatch( InstanceData * _coid_inst_data, uint _coid_fnc_id, binstream& _coid_bstr, metastream* coid_meta=0 );
metastream& COID_maps_4_0_getmeta();



struct DISPATCH_CALLER_maps_4_0
{
	void call_dispatch( binstream * b ) {
		COID_CLIENT_EXESTREAM_ARGS * a = (COID_CLIENT_EXESTREAM_ARGS *) this;
		InstanceData d;  d._object = a->obj;
		COID_maps_4_0_dispatch( &d, a->id, *b );
	}
};





enum {	/// command ids, format is: COID_classname_fncname_fncid
	COID_maps_get_image_by_XY_0 = 0,
	COID_maps_get_image_by_lon_lat_1 = 1,
	COID_maps_change_zoom_2 = 2,

    COID_maps_accept_connect_5,
    COID_maps_accept_connect_shared_6
};



/// info about every function:
static const char * COID_maps_get_image_by_XY_0_finfo[] = {"get_image_by_XY", "opcd ", "cImagePosition & imagePosition", NULL, "cMapImage & imageOut", NULL};
static const char * COID_maps_get_image_by_lon_lat_1_finfo[] = {"get_image_by_lon_lat", "opcd ", "cImagePosition & imagePosition", NULL, "cMapImage & imageOut", NULL};
static const char * COID_maps_change_zoom_2_finfo[] = {"change_zoom", "opcd ", "cImagePosition & imagePosition", NULL, "cConfiguration & configuration", NULL};
static const char * COID_maps_accept_connect_5_finfo[] = {"accept_connect", "opcd ", "int start_lat", "int start_lon", "int start_zoom", NULL, "cConfiguration & configuration", NULL};
static const char * COID_maps_accept_connect_shared_6_finfo[] = {"accept_connect_shared", "opcd ", NULL, NULL};


/// create structure that holds everything about function:
static const MethodDesc COID_maps_method_desc[] = {
	COID_MethodDesc_constructor( COID_maps_get_image_by_XY_0_finfo, 0, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fMETA | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_maps_get_image_by_lon_lat_1_finfo, 1, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fMETA | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_maps_change_zoom_2_finfo, 2, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fMETA | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_maps_accept_connect_5_finfo, 2147483653, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fMETA | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_maps_accept_connect_shared_6_finfo, 2147483654, MethodDesc::fLOG_CALL )
};



static const char * COID_dependencies_maps[] = {

	NULL
};


/// ServiceDescriptor:
static ServiceDescriptor COID_descriptor_maps;



/// dispatch stores function tables for all 'direct' clients with different minor versions here
class COID_register_maps_4_0
{
	struct table {
		uint ver;
		coid_fnc * tbl;
	};
	dynarray<table>	_tables;

public:
//	comm_mutex_rw	_mx;
	comm_mutex	_mx;
   const void* (*dummyreg)();

	COID_register_maps_4_0() {
		COID_descriptor_maps._version.set( "", 4, 0, 25 );
		COID_descriptor_maps._coid_version = COID_VERSION;
		COID_descriptor_maps._name = "maps";
		COID_descriptor_maps._shortname = "maps";
		COID_descriptor_maps._info = "";
		COID_descriptor_maps._dependencies = COID_dependencies_maps;
		COID_descriptor_maps._nmeth = 3;
		COID_descriptor_maps._methflags = COID_maps_method_desc;
		COID_descriptor_maps._flags = ServiceDescriptor::fLOG_CALL | ServiceDescriptor::fALLOW_DIRECT_ACCESS | ServiceDescriptor::fALLOW_INTERPROCESS_ACCESS | ServiceDescriptor::fALLOW_REMOTE_ACCESS | ServiceDescriptor::fAUTONOMOUS;
		COID_descriptor_maps._acceptor_port = (uint) -1;
		COID_descriptor_maps._bin_svc_data = COID_bin_data;
		COID_descriptor_maps.get_method_id = COID_maps_4_0_get_method_id;
		COID_descriptor_maps.dispatch = COID_maps_4_0_dispatch;
		COID_descriptor_maps._fnc_get_meta = COID_maps_4_0_getmeta;
#ifdef _DEBUG
		COID_descriptor_maps._flags |= ServiceDescriptor::fDEBUG;
#endif
		_mx.set_name( "COID_register_maps_4_0" );
		INTERFACE_REGISTER(ServiceDescriptor).add( &COID_descriptor_maps );
	}

	~COID_register_maps_4_0() {
//		MXGUARDRW( (comm_mutex_rw &) _mx );
		MXGUARD( (comm_mutex &) _mx );
		for( uint i=0; i<_tables.size(); i++ )
			delete [] _tables[i].tbl;
	}
	coid_fnc * get_table_notlocked( uint ver ) {
		for( uint i=0; i<_tables.size(); i++ )
			if( ver == _tables[i].ver ) return _tables[i].tbl;
		return NULL;
	}
	coid_fnc * get_table( uint ver ) {
//		MXGUARDRW( (const comm_mutex_rw &) _mx );		/// ==> read lock
		MXGUARD( (const comm_mutex &) _mx );
		return get_table_notlocked( ver );
	}
	void insert_table( uint ver, coid_fnc * tbl ) {
		table * t = _tables.add( 1 );	/// mutex has been locked
		t->ver = ver; t->tbl = tbl;
	}
};


// for dll linking
COID_register_maps_4_0 & get_COID_register_maps_4_0()
{
	static COID_register_maps_4_0 x;
	x.dummyreg = &coid_get_sdir2;    //force exporting the symbol
	x.dummyreg();
	return x;
}

//for static linking (must be called from outside to link this object)
void get_COID_register_maps()
{
	COID_register_maps_4_0();
}

static COID_register_maps_4_0 & COID_auto_register_variable = get_COID_register_maps_4_0();





metastream& COID_maps_4_0_getmeta()
{
    static metastream* meta = 0;
    if(meta)  return *meta;

    meta = new metastream;
    ServiceDescriptor::MethodDesc* med=0;
#define META_TD(TY)     metastream::TypeDesc< TY >::get_str(*meta)

    {   //COID_maps_accept_connect_5
        med = (ServiceDescriptor::MethodDesc*)&COID_descriptor_maps._methflags[COID_maps_accept_connect_5];
        med->retval.meta = META_TD(opcd);

		med->inargs[0].meta = META_TD(int);
		med->inargs[1].meta = META_TD(int);
		med->inargs[2].meta = META_TD(int);
		med->outargs[0].meta = META_TD(cConfiguration);
    }
    {   //COID_maps_accept_connect_shared_6
        med = (ServiceDescriptor::MethodDesc*)&COID_descriptor_maps._methflags[COID_descriptor_maps._nmeth+1];
        med->retval.meta = META_TD(opcd);
    }
    {   //COID_maps_get_image_by_XY_0
        med = (ServiceDescriptor::MethodDesc*)&COID_descriptor_maps._methflags[COID_maps_get_image_by_XY_0];
        med->retval.meta = META_TD(opcd);

		med->inargs[0].meta = META_TD(cImagePosition);
		med->outargs[0].meta = META_TD(cMapImage);
    }
    {   //COID_maps_get_image_by_lon_lat_1
        med = (ServiceDescriptor::MethodDesc*)&COID_descriptor_maps._methflags[COID_maps_get_image_by_lon_lat_1];
        med->retval.meta = META_TD(opcd);

		med->inargs[0].meta = META_TD(cImagePosition);
		med->outargs[0].meta = META_TD(cMapImage);
    }
    {   //COID_maps_change_zoom_2
        med = (ServiceDescriptor::MethodDesc*)&COID_descriptor_maps._methflags[COID_maps_change_zoom_2];
        med->retval.meta = META_TD(opcd);

		med->inargs[0].meta = META_TD(cImagePosition);
		med->outargs[0].meta = META_TD(cConfiguration);
    }

    return *meta;
}



///////////////////////////////////////////////////////////////////////////////
opcd COID_maps_4_0_dispatch( InstanceData* _coid_inst_data, uint _coid_fnc_id, binstream& _coid_bstr, metastream* coid_meta )
{
	maps * _coid_maps_obj = (maps *) _coid_inst_data->_object;
	double _coid_maps_ticks = 0.0;
	binstream * _coid_log = NULL;
	opcd _coid_err_code = 0;

	switch( _coid_fnc_id ) {
		case StdDispatchMethod::CONSTRUCTOR: {
			_coid_inst_data->_object = _coid_maps_obj = new maps;
       } break;
		case StdDispatchMethod::POSTCONSTRUCTOR: {
			_coid_err_code = 0;
		} break;
		case StdDispatchMethod::DESTRUCTOR: {
			delete _coid_maps_obj; _coid_inst_data->_object = NULL;
		} break;
		case StdDispatchMethod::CREATE_INTERFACE: {
			CreateInterfaceInfo* coid_iface_info;
			_coid_bstr.read_ptr(coid_iface_info);
			const uint coid_fnc_count = coid_iface_info->_nmethods;
			const uint * coid_flags = coid_iface_info->_methflags;
			coid_fnc * coid_fnc_table = get_COID_register_maps_4_0().get_table( coid_iface_info->_clientver.get_minor() );

			if( !coid_fnc_table ) {
				//MXGUARDRW( get_COID_register_maps_4_0()._mx );
				MXGUARD( get_COID_register_maps_4_0()._mx );
				coid_fnc_table = get_COID_register_maps_4_0().get_table_notlocked( coid_iface_info->_clientver.get_minor() );
				if( !coid_fnc_table ) {
					coid_fnc_table = (coid_fnc *) new char[ sizeof(coid_fnc) * (coid_fnc_count + 1) ];	/// new coid_fnc[...] would allocate pointer to 0 bytes (M$ 'feature')
					memset( coid_fnc_table, 0, (coid_fnc_count + 1) * sizeof(coid_fnc) );
					uint coid_table_index = 0;

					((CreateInterfaceInfo::t_fnc *) coid_fnc_table)[coid_table_index++] = coid_iface_info->_disconnect_interface;
					COID_DISPATCH_CREATE_HOOK( get_image_by_XY, 0, coid_table_index++, opcd (maps::*)(cImagePosition & , cMapImage & ) )
					COID_DISPATCH_CREATE_HOOK( get_image_by_lon_lat, 1, coid_table_index++, opcd (maps::*)(cImagePosition & , cMapImage & ) )
					COID_DISPATCH_CREATE_HOOK( change_zoom, 2, coid_table_index++, opcd (maps::*)( cImagePosition & , cConfiguration &  ) )

					get_COID_register_maps_4_0().insert_table( coid_iface_info->_clientver.get_minor(), coid_fnc_table );
				}
			}

			_coid_bstr.acknowledge();
			_coid_bstr.write_ptr( coid_fnc_table );
			_coid_bstr.write_ptr( _coid_inst_data->_object );
			_coid_bstr.write_ptr( coid_iface_info->_mutex );
		} break;
		case StdDispatchMethod::AUTHENTIFY: {
			if( (_coid_inst_data->_flags & (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_maps_ticks = SINGLETON(HPTIMER).ftime();
			
			int start_lat;
			if(coid_meta)  coid_meta->xstream_in(start_lat, "start_lat"); else  _coid_bstr >> start_lat;
			int start_lon;
			if(coid_meta)  coid_meta->xstream_in(start_lon, "start_lon"); else  _coid_bstr >> start_lon;
			int start_zoom;
			if(coid_meta)  coid_meta->xstream_in(start_zoom, "start_zoom"); else  _coid_bstr >> start_zoom;
			cConfiguration configuration;

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				_coid_log = &_coid_inst_data->_cmdin->post_method();
				*_coid_log << "(" << "80000005" << ") accept_connect ( "; *_coid_log << start_lat; *_coid_log << ", "; *_coid_log << start_lon; *_coid_log << ", "; *_coid_log << start_zoom; *_coid_log << ", "; *_coid_log << "?"; *_coid_log << " )";
			}

			_coid_bstr.acknowledge();

			_coid_err_code = _coid_maps_obj->accept_connect( start_lat, start_lon, start_zoom, configuration );
			if(coid_meta)  coid_meta->xstream_out(_coid_err_code,"err");  else  _coid_bstr << _coid_err_code;
			if( ! _coid_err_code ) {
				if(coid_meta)  coid_meta->xstream_out( configuration, "configuration" );  else  _coid_bstr << configuration;
			}


			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				*_coid_log << "  -->  ("; *_coid_log << configuration; *_coid_log << ")";
				if( _coid_inst_data->_flags & MethodDesc::fLOG_DURATION )
					*_coid_log << " [" << (SINGLETON(HPTIMER).ftime() - _coid_maps_ticks) * 1000 << "]";
				if( !_coid_err_code ) *_coid_log << " .. ok" << EOM;
				else *_coid_log << " .. fail: " << opcd_formatter(_coid_err_code) << EOM;
			}
			
		} break;
		case StdDispatchMethod::AUTHENTIFY_SHARED: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			return ersNOT_IMPLEMENTED;
		} break;
		case StdDispatchMethod::AUTHENTIFY_AUTO: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		} break;
		case StdDispatchMethod::HANDLE_NET_LOOP: {
			return ersNOT_IMPLEMENTED;
		} break;
		case StdDispatchMethod::PREDESTRUCTOR: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		} break;
		case StdDispatchMethod::COMMAND: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		} break;
		case StdDispatchMethod::SPAWN: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		} break;
		case StdDispatchMethod::ECHO: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		} break;


		/// service-specific methods:
		case COID_maps_get_image_by_XY_0: {
			if( (_coid_inst_data->_flags & (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_maps_ticks = SINGLETON(HPTIMER).ftime();
			
			cImagePosition imagePosition;
			if(coid_meta)  coid_meta->xstream_in(imagePosition, "imagePosition"); else  _coid_bstr >> imagePosition;
			cMapImage imageOut;

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				_coid_log = &_coid_inst_data->_cmdin->post_method();
				*_coid_log << "(" << COID_maps_get_image_by_XY_0 << ") get_image_by_XY ( "; *_coid_log << imagePosition; *_coid_log << ", "; *_coid_log << "?"; *_coid_log << " )";
			}

			_coid_bstr.acknowledge();

			_coid_err_code = _coid_maps_obj->get_image_by_XY( imagePosition, imageOut );
			if(coid_meta)  coid_meta->xstream_out(_coid_err_code,"err");  else  _coid_bstr << _coid_err_code;
			if( ! _coid_err_code ) {
				if(coid_meta)  coid_meta->xstream_out( imageOut, "imageOut" );  else  _coid_bstr << imageOut;
			}

			_coid_bstr.flush();

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				*_coid_log << "  -->  ("; *_coid_log << imageOut; *_coid_log << ")";
				if( _coid_inst_data->_flags & MethodDesc::fLOG_DURATION )
					*_coid_log << " [" << (SINGLETON(HPTIMER).ftime() - _coid_maps_ticks) * 1000 << "]";
				if( !_coid_err_code ) *_coid_log << " .. ok" << EOM;
				else *_coid_log << " .. fail: " << opcd_formatter(_coid_err_code) << EOM;
			}
			
		} break;
		case COID_maps_get_image_by_lon_lat_1: {
			if( (_coid_inst_data->_flags & (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_maps_ticks = SINGLETON(HPTIMER).ftime();
			
			cImagePosition imagePosition;
			if(coid_meta)  coid_meta->xstream_in(imagePosition, "imagePosition"); else  _coid_bstr >> imagePosition;
			cMapImage imageOut;

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				_coid_log = &_coid_inst_data->_cmdin->post_method();
				*_coid_log << "(" << COID_maps_get_image_by_lon_lat_1 << ") get_image_by_lon_lat ( "; *_coid_log << imagePosition; *_coid_log << ", "; *_coid_log << "?"; *_coid_log << " )";
			}

			_coid_bstr.acknowledge();

			_coid_err_code = _coid_maps_obj->get_image_by_lon_lat( imagePosition, imageOut );
			if(coid_meta)  coid_meta->xstream_out(_coid_err_code,"err");  else  _coid_bstr << _coid_err_code;
			if( ! _coid_err_code ) {
				if(coid_meta)  coid_meta->xstream_out( imageOut, "imageOut" );  else  _coid_bstr << imageOut;
			}

			_coid_bstr.flush();

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				*_coid_log << "  -->  ("; *_coid_log << imageOut; *_coid_log << ")";
				if( _coid_inst_data->_flags & MethodDesc::fLOG_DURATION )
					*_coid_log << " [" << (SINGLETON(HPTIMER).ftime() - _coid_maps_ticks) * 1000 << "]";
				if( !_coid_err_code ) *_coid_log << " .. ok" << EOM;
				else *_coid_log << " .. fail: " << opcd_formatter(_coid_err_code) << EOM;
			}
			
		} break;
		case COID_maps_change_zoom_2: {
			if( (_coid_inst_data->_flags & (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_maps_ticks = SINGLETON(HPTIMER).ftime();
			
			cImagePosition imagePosition;
			if(coid_meta)  coid_meta->xstream_in(imagePosition, "imagePosition"); else  _coid_bstr >> imagePosition;
			cConfiguration configuration;

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				_coid_log = &_coid_inst_data->_cmdin->post_method();
				*_coid_log << "(" << COID_maps_change_zoom_2 << ") change_zoom ( "; *_coid_log << imagePosition; *_coid_log << ", "; *_coid_log << "?"; *_coid_log << " )";
			}

			_coid_bstr.acknowledge();

			_coid_err_code = _coid_maps_obj->change_zoom( imagePosition, configuration );
			if(coid_meta)  coid_meta->xstream_out(_coid_err_code,"err");  else  _coid_bstr << _coid_err_code;
			if( ! _coid_err_code ) {
				if(coid_meta)  coid_meta->xstream_out( configuration, "configuration" );  else  _coid_bstr << configuration;
			}

			_coid_bstr.flush();

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				*_coid_log << "  -->  ("; *_coid_log << configuration; *_coid_log << ")";
				if( _coid_inst_data->_flags & MethodDesc::fLOG_DURATION )
					*_coid_log << " [" << (SINGLETON(HPTIMER).ftime() - _coid_maps_ticks) * 1000 << "]";
				if( !_coid_err_code ) *_coid_log << " .. ok" << EOM;
				else *_coid_log << " .. fail: " << opcd_formatter(_coid_err_code) << EOM;
			}
			
		} break;


		default:
			_coid_bstr.acknowledge( true );
			_coid_bstr << ersNOT_IMPLEMENTED;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		break;
	}



	return _coid_err_code;
}












/// method table
static METHOD_TABLE COID_maps_method_table[] = {
	{"get_image_by_lon_lat", COID_maps_get_image_by_lon_lat_1},
	{"change_zoom", COID_maps_change_zoom_2},
	{NULL, UMAX},
	{NULL, UMAX},
	{"get_image_by_XY", COID_maps_get_image_by_XY_0}
};



#define COID_dispatch_method_size		(sizeof(COID_maps_method_table) / sizeof(METHOD_TABLE))



uint COID_maps_4_0_get_method_id( const token & name )
{
	hash<token> mha;
	uints idx = mha(name) % COID_dispatch_method_size;

	for( uint i=0; i<COID_dispatch_method_size; i++ ) {
		if( COID_maps_method_table[idx].name )
			if( name == COID_maps_method_table[idx].name )
				return COID_maps_method_table[idx].id;
		idx++;
		if( idx == COID_dispatch_method_size ) idx = 0;
	}

	return UMAX;
}


} // namespace coid
